﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Connection;
using Connection.Presenter;

namespace Server
{

    public partial class MainWindow : Window
    {
        private TcpChannel tcpChannel;
        private WellKnownObjectMode mode =WellKnownObjectMode.Singleton;
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            tcpChannel = new TcpChannel(Int32.Parse(txtPort.Text));
            //tcpChannel = new TcpChannel(8088);
            ChannelServices.RegisterChannel(tcpChannel, false);

            //dang ky doi tuong USER
            //RemotingConfiguration.RegisterWellKnownServiceType(typeof(UserDB), "USERDB_OBJECT", mode);
            //dang ky doi tuong Login Presenter
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(LoginPresenter), "PRESENTER/LOGINPRESENTER_OBJECT", mode);
            //dang ky doi tuong Invi Presenter
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(InviPresenter), "PRESENTER/INVIPRESENTER_OBJECT", mode);
            //dang ky doi tuong Chat Presenter
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(ChatPresenter), "PRESENTER/CHATPRESENTER_OBJECT", mode);
            //dang ky doi tuong SignUp Presenter
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(SignUpPresenter), "PRESENTER/SIGNUPPRESENTER_OBJECT", mode);

            lblTrangThai.Content = "Server đã khởi động";
        }
    }
}
